#include "stdafx.h"	//

#ifdef _DEBUG
	#undef THIS_FILE
	static char THIS_FILE[] = __FILE__;
	#undef DEBUG_NEW
	#define	DEBUG_NEW new(_NORMAL_BLOCK,__FILE__,__LINE__)
	#define new DEBUG_NEW
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
DBDATA_API void reset_strategy_matlab_future_trade_daying(void)
{
	EnterCriticalSection(&__matlab_lock_strategy__);
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_100m.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_100m[ii]);
	}
	_strategy_future_trade_daying_vtor_100m.clear();
	//
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_50m.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_50m[ii]);
	}
	_strategy_future_trade_daying_vtor_50m.clear();
	//
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_v10.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_v10[ii]);
	}
	_strategy_future_trade_daying_vtor_v10.clear();
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_smart.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_smart[ii]);
	}
	_strategy_future_trade_daying_vtor_smart.clear();
	STRATEGY_Version_FutureTradeDaying_100m++;
	STRATEGY_Version_FutureTradeDaying_50m++;
	STRATEGY_Version_FutureTradeDaying_v10++;
	STRATEGY_Version_FutureTradeDaying_smart++;
	
	//
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_AA.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_AA[ii]);
	}
	_strategy_future_trade_daying_vtor_AA.clear();
	STRATEGY_Version_FutureTradeDaying_AA++;
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_BB.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_BB[ii]);
	}
	_strategy_future_trade_daying_vtor_BB.clear();
	STRATEGY_Version_FutureTradeDaying_BB++;
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_CC.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_CC[ii]);
	}
	_strategy_future_trade_daying_vtor_CC.clear();
	STRATEGY_Version_FutureTradeDaying_CC++;
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_DD.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_DD[ii]);
	}
	_strategy_future_trade_daying_vtor_DD.clear();
	STRATEGY_Version_FutureTradeDaying_DD++;

	//
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_a.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_a[ii]);
	}
	_strategy_future_trade_daying_vtor_a.clear();
	STRATEGY_Version_FutureTradeDaying_a++;
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_b.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_b[ii]);
	}
	_strategy_future_trade_daying_vtor_b.clear();
	STRATEGY_Version_FutureTradeDaying_b++;
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_c.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_c[ii]);
	}
	_strategy_future_trade_daying_vtor_c.clear();
	STRATEGY_Version_FutureTradeDaying_c++;
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_d.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_d[ii]);
	}
	_strategy_future_trade_daying_vtor_d.clear();
	STRATEGY_Version_FutureTradeDaying_d++;

	//
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_aa.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_aa[ii]);
	}
	_strategy_future_trade_daying_vtor_aa.clear();
	STRATEGY_Version_FutureTradeDaying_aa++;
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_bb.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_bb[ii]);
	}
	_strategy_future_trade_daying_vtor_bb.clear();
	STRATEGY_Version_FutureTradeDaying_bb++;
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_cc.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_cc[ii]);
	}
	_strategy_future_trade_daying_vtor_cc.clear();
	STRATEGY_Version_FutureTradeDaying_cc++;
	for(int ii=0; ii<(int)_strategy_future_trade_daying_vtor_dd.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_future_trade_daying_vtor_dd[ii]);
	}
	_strategy_future_trade_daying_vtor_dd.clear();
	STRATEGY_Version_FutureTradeDaying_dd++;

	LeaveCriticalSection(&__matlab_lock_strategy__);
}

DBDATA_API void reset_strategy_lzzj_trade_daying(void)
{
	EnterCriticalSection(&__matlab_lock_strategy__);
	for(int ii=0; ii<(int)_strategy_lzzj_trade_daying_vtor_A.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_lzzj_trade_daying_vtor_A[ii]);
	}
	STRATEGY_Version_lzzj_A++;

	for(int ii=0; ii<(int)_strategy_lzzj_trade_daying_vtor_B.size();ii++)
	{
		DELETE_PTRA((ptrade_daying_item)_strategy_lzzj_trade_daying_vtor_B[ii]);
	}
	STRATEGY_Version_lzzj_B++;
	LeaveCriticalSection(&__matlab_lock_strategy__);
}

DBDATA_API void reset_strategy_matlab_etf_trade_daying(void)
{
	EnterCriticalSection(&__matlab_lock_strategy__);
	for(int ii=0;ii<_etf_matlab_code_count;ii++)
	{
		for(int iii=0;iii<(int)_strategy_etf_trade_daying_vtor[ii].size();iii++)
		{
			DELETE_PTRA((ptrade_daying_item)_strategy_etf_trade_daying_vtor[ii][iii]);
		}
		for(int iii=0;iii<(int)_strategy_etf_trade_daying_vtor_b[ii].size();iii++)
		{
			DELETE_PTRA((ptrade_daying_item)_strategy_etf_trade_daying_vtor_b[ii][iii]);
		}
		_strategy_etf_trade_daying_vtor[ii].clear();
		_strategy_etf_trade_daying_vtor_b[ii].clear();
		STRATEGY_Version_ETFTradeDaying2[ii]++;
		STRATEGY_Version_ETFTradeDaying2_b[ii]++;
	}
	LeaveCriticalSection(&__matlab_lock_strategy__);
}

DBDATA_API void reset_db_strategy_trade_daying(void)
{
	EnterCriticalSection(&__dbdata_lock_strategy__);

	for(int ii=0; ii<(int)_db_strategy_trade_daying_map_gp.size();ii++)
	{
		map<string,ptrade_daying_itemex>::const_iterator map_iter = _db_strategy_trade_daying_map_gp[ii].begin();
		for(;map_iter != _db_strategy_trade_daying_map_gp[ii].end(); map_iter++)
		{
			DELETE_PTRA((ptrade_daying_itemex)map_iter->second);
		}
	}
	_db_strategy_trade_daying_map_gp.clear();

	for(int ii=0; ii<(int)_db_strategy_trade_daying_map_dp.size();ii++)
	{
		map<string,ptrade_daying_itemex>::const_iterator map_iter = _db_strategy_trade_daying_map_dp[ii].begin();
		for(;map_iter != _db_strategy_trade_daying_map_dp[ii].end(); map_iter++)
		{
			DELETE_PTRA((ptrade_daying_itemex)map_iter->second);
		}
	}
	_db_strategy_trade_daying_map_dp.clear();
	//_db_newlevel_map_dp.clear();
	
	STRATEGY_Version_FutureTradeDaying_db_gp = 0;
	STRATEGY_Version_FutureTradeDaying_db_dp = 0;

	LeaveCriticalSection(&__dbdata_lock_strategy__);
}

//
DBDATA_API bool read_strategy_stock_trade_daying_hist(preq_strategy_trade_daying preq,pans_strategy_trade_daying pans)
{
	return FALSE;
}
//
DBDATA_API bool read_strategy_future_trade_daying_hist(preq_strategy_trade_daying preq,pans_strategy_trade_daying pans)
{
	return FALSE;
}
